﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using DTO;

namespace DAO
{

	public class TblTrangThaiBillDAO:IData<TblTrangThaiBill> 
 	{
		public TblTrangThaiBillDAO(String myconnecString) : base(myconnecString) { }

		protected override int InsertOnSubmit(ref TblTrangThaiBill item, int t) {
			 return connec.ExecuteNonQuery("sp_TblTrangThaiBill", CommandType.StoredProcedure,new SqlParameter("@flag", t),
				 new SqlParameter("@" + TblTrangThaiBill.c_MaTrangThai, item.MaTrangThai), new SqlParameter("@" + TblTrangThaiBill.c_TenTrangThai, item.TenTrangThai),
				 new SqlParameter("@" + TblTrangThaiBill.c_DaXoa, item.DaXoa));
		}

		public override TblTrangThaiBill GetItem(IDataReader dr)
		{
			TblTrangThaiBill obj = new TblTrangThaiBill();
			obj.MaTrangThai = Convert.ToInt32(dr[TblTrangThaiBill.c_MaTrangThai]);
			obj.TenTrangThai = Convert.ToString(dr[TblTrangThaiBill.c_TenTrangThai]);
			obj.DaXoa = Convert.ToBoolean(dr[TblTrangThaiBill.c_DaXoa]);
			return obj;
		}

		public override List<TblTrangThaiBill> GetAll()
		{
			return GetAll("sp_GetAllTblTrangThaiBill", CommandType.StoredProcedure);
		}

		public override TblTrangThaiBill GetItemById(object id)
		{
			return GetAll().SingleOrDefault(p => p.MaTrangThai == Convert.ToInt32(id));
		}
		public override TblTrangThaiBill GetItemById(TblTrangThaiBill item){
			throw new NotImplementedException();
		}

	}

 }
